Retry

object Retry

JS/TS-friendly facades over this library's top-level retry functions.

import { retryWithExponentialBackoff } from "arrow-resilience-kit";

const data = await retryWithExponentialBackoff(() => callFlakyService(), 5, 100);

Functions

Link copied to clipboard
fun <T> ifMatches(block: () -> Promise<T>, shouldRetry: (message: String?) -> Boolean, retries: Int = 3, delayMillis: Double): Promise<T>

Retries block with a fixed delay, but only while shouldRetry (given the error's message) returns true.

Link copied to clipboard
fun <T> orDefault(block: () -> Promise<T>, fallback: (message: String?) -> Promise<T>, retries: Int = 3, baseMillis: Double = 200.0, factor: Double = 2.0): Promise<T>

Retries block with exponential backoff, falling back to fallback (given the error's message) if every attempt fails.

Link copied to clipboard
fun <T> withConstantDelay(block: () -> Promise<T>, retries: Int = 3, delayMillis: Double): Promise<T>

Retries block with a fixed delay between attempts.

Link copied to clipboard
fun <T> withExponentialBackoff(block: () -> Promise<T>, retries: Int = 3, baseMillis: Double = 200.0, factor: Double = 2.0): Promise<T>

Retries block with exponential backoff and jitter.